#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct ChunkInfo
 {
  unsigned short ID;
  int Size;
 };
 
struct Vertex
 {
  float x,y,z;
 };
 
struct Face
 {
  unsigned short p1,p2,p3;
 };
 
struct UVCoord
 {
  float U,V;
 };
 
struct ObjMesh
 {
  Vertex *vtx;
  Vertex *norm;
  int nVtx,nFace,nUV;
  Face *face;
  UVCoord *UV;
  char MatName[64];
 };
 
struct ObjMatl
 {
  char Name[64];
  unsigned int Red,Green,Blue;
  char TexName[64];
  int Smooth;
 };
 
 
class Obj3DS
 {
  public:
 
   int fSize;
   unsigned char *data;
   int nMesh,nMatl;
 
   ObjMesh *Mesh;
   ObjMatl *Matl;
 
   Obj3DS();
   ~Obj3DS();
   int CountParts(int DataLen);
   int Load(char *fName);
   ChunkInfo GetChunkInfo(int Offset);
   void Get3fVector(int offset,float &x1,float &x2,float &x3);
   void Get3Vector(int offset,unsigned short &x1,unsigned short &x2,unsigned short &x3);
   void Get2fVector(int offset,float &x1,float &x2);
 };